<?php 
global $_GPC, $_W;
$GLOBALS['frames'] = $this->getMainMenu();
$cates = pdo_getall('snx_course',array('uniacid'=>$_W['uniacid']));
$info = pdo_get('snx_class',array('id'=>$_GPC['id']));
if(checksubmit('submit')){
        $data['class_name']=$_GPC['class_name'];
        $data['sort']=$_GPC['sort'];
        $data['cou_id']=$_GPC['name'];
        $data['create_time']=date('Y-m-d H:i:s',time());
        $data['uniacid']=$_W['uniacid'];
        if (empty($_GPC['name'])) {
             message('课程不能为空','','error');
        }
        $res = pdo_get('snx_class',array('cou_id'=>$_GPC['name'],'class_name'=>$_GPC['class_name'],'uniacid'=>$_W['uniacid']),array('cou_id','class_name'));
        if ($res) {
            message('该课程下班级已经存在','','error');
        }if($_GPC['id']==''){  
            $rst=pdo_insert('snx_class',$data);      
            if($rst){
                 message('添加成功！', $this->createWebUrl('class'), 'success');
            }else{
                 message('添加失败！','','error');
            }
        }else{
             $rst=pdo_update('snx_class',$data,array('id'=>$_GPC['id']));
            if($rst){
                 message('编辑成功！', $this->createWebUrl('class'), 'success');
            }else{
                 message('编辑失败！','','error');
            }
        }
}
include $this->template('web/addclass');
 ?>